<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // const person = {
        //     name: 'Cai',
        //     age: 9,
        //     hobby: 'play'
        // }

        // console.log(Object.keys(person))
        // console.log(Object.values(person));
        // console.log(Object.entries(person));


        //与数组类似方法的区别
        //数组的keys()、values()、entries()的方法是实例方法，返回的都是Iterator
        //对象的Object.keys()、Object.values()、Object.entries()等方法是构造方法 返回的是数组
        console.log([1, 2, 3].keys());
        console.log([1, 2, 3].values());
        console.log([1, 2, 3].entries());


        const person = {
            name: 'Cai',
            age: 9,
            hobby: 'play'
        }

        //使用for of遍历对象

        // for (const entries of Object.entries(person)) {
        //     console.log(entries);
        // }

        for (const [key, value] of Object.entries(person)) {
            console.log([key, value]);
        }
    </script>
</body>

</html>